package 
{
	import ui.GameCamera;
	import ui.UIFade;
	import ui.UIMap;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	/**
	 * ...
	 * @author Surui
	 */
	public class Main extends Sprite 
	{
		private var m_fade:UIFade = UIFade.self;
		private var m_timer:Timer = new Timer(1000 / 24);
		public function Main():void 
		{
			if (stage) {
				init();
				GameCamera.self.setStage(stage);
			} else {
				addEventListener(Event.ADDED_TO_STAGE, init);
			}
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			stage.scaleMode = "noScale";
			
			this.addChild(m_fade);
			
			m_timer.addEventListener(TimerEvent.TIMER, gameLoop);
			m_timer.start();
			
		}
		
		private function gameLoop( event:TimerEvent ):void {
			GameCamera.self.update();
		}
		
	}
	
}